﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace 学生信息管理系统
{
    public partial class Student : Form
    {
        public Student()
        {
            InitializeComponent();
        }

        private void Student_Load(object sender, EventArgs e)
        {
            
        }

        public Student(String s)
        {
            InitializeComponent();
            this.txtName.Text = s;
        }

        private void 我的信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
                    string cn_str = pub.CN_STR;
                    OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
                    cn.Open();
                    string select = "select * from 学生信息 where 学号='" + txtName.Text + "'";
                    OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
                    OleDbDataReader reader = cmd.ExecuteReader();
                    DataTable dt = new DataTable();
                    dt.Load(reader);
                    this.dataGridView1.DataSource = dt;
                    cn.Close();
        }

        private void 大一上学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "select * from 大一上学期 where 学号='" + txtName.Text + "'";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 大一下学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "select * from 大一下学期 where 学号='" + txtName.Text + "'";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 大二上学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "select * from 大二上学期 where 学号='" + txtName.Text + "'";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 大二下学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "select * from 大二下学期 where 学号='" + txtName.Text + "'";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 大三上学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "select * from 大三上学期 where 学号='" + txtName.Text + "'";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StudentPassword f = new StudentPassword();
            f = new StudentPassword(txtName.Text);
            DialogResult r = f.ShowDialog();
            this.IsMdiContainer = true;
            f.MdiParent = this;
            
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void 返回主页面ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Login ff = new Login();
            ff.Show();
            this.Hide();
            
        }

    }
}
